const mongoose = require('mongoose')

mongoose.connect('mongodb://127.0.0.1:27017/data');

mongoose.connection.on('open',()=>{
    //创建数据骨架
    let userSchema = new mongoose.Schema({
        name:{
            type:String,
            default:'yuonly',
            unique:true
        },
        age:{
            type:String,
            default:20
        }
    })

    let userModel = mongoose.model('user',userSchema);
    // userModel.deleteOne({_id:'62b48164aa4f59ff60f8ef7b'},(err,data)=>{
    //     if(err) throw err;
    //     console.log(data);
    // })

    userModel.deleteMany({age:18},(err,data)=>{
        if(err) throw err;
        console.log(data);
    })
    
})